/*
 * @Author: 张小平
 * @Date:   2025-05-01
 * @Email:  qqshuqian@163.com
 * @Copyright © 2024 aseyun. All rights reserved.
 */
import request from '@/framework-core/axios';
import website from '@/framework-core/config/website';

export const loginByUsername = (username, password, captchaType, code,temptoken) => request({
  url: website.baseUrl+'/api/sys/login',
  method: 'post',
  params: {'username': username, 'password': password,"captchaType":captchaType,"code":code,"temptoken":temptoken},
})


export const loginByFace = (username, face,temptoken) => request({
  url: website.baseUrl+'/api/sys/loginFace',
  method: 'post',
  params: {'username': username,face:face,"temptoken":temptoken},
})


export const getUserInfo = () => request({
  url: website.baseUrl + '/api/sys/info',
  method: 'get'
});

export const refreshToken = () => request({
  url: website.baseUrl + '/user/refresh',
  method: 'post'
})


export const sendLogs = (list) => request({
  url: website.baseUrl + '/user/logout',
  method: 'post',
  data: list
})

export const logout = () => request({
  url: website.baseUrl + '/api/sys/logout',
  meta: {
    isToken: false
  },
  method: 'post'
})


export const getPubMenusInfo = () => request({
  url: website.baseUrl + '/api/sys/pubmenus',
  meta: {
    isToken: false
  },
  method: 'get'
})

export const getDicList = () => request({
  url: website.baseUrl + '/api/sys/dic/list',
  meta: {
    isToken: false
  },
  method: 'post',
  data:{}
})

export const getNoticePage = (data) =>
    request({
  url: website.baseUrl + '/api/webMessage/tWebsiteMessage/pageUserMessage',
  meta: {
    isToken: false
  },
  method: 'post',
  data:data
})

export const getUnreadNoticeNum = (data) =>
    request({
      url: website.baseUrl + '/api/webMessage/tWebsiteMessage/countMessage',
      method: 'post',
      data:data
    })

export const switchTenatRole = (tenantId,roleId,orgId) => request({
  url: website.baseUrl + '/api/sys/switchTenatRole?tenantId='+tenantId+"&roleId="+roleId+"&orgId="+orgId,
  meta: {
    isToken: false
  },
  method: 'get'
})

/**
 * 更新消息状态
 * @param path
 * @param obj
 */
export function updateMsg(obj) {
  return request({
    url: website.baseUrl+'/api/webMessage/tWebsiteMessageread/save',
    method: 'post',
    data: obj
  })
}


/**
 * 第三方授权
 * @param source
 */
export function renderAuth(source) {
  return request({
    url: website.baseUrl+'/api/auth/render/'+source,
    method: 'get'
  })
}

/**
 * 第三方授权
 * @param source
 */
export function authlogin(token) {
  return request({
    url: website.baseUrl+'/api/sys/authlogin?temptoken='+token,
    method: 'POST'
  })
}

/**
 * 更新密码
 * @param password
 * @param newPassword
 */
export function updatePassword(password,newPassword) {
  return request({
    url: website.baseUrl + '/api/sys/user/psw/update',
    data: {"password": password, "newPassword": newPassword},
    method: 'post'
  });
}



